package com.neuedu.studentmanage.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.neuedu.studentmanage.entity.Pager;
import com.neuedu.studentmanage.entity.Result;
import com.neuedu.studentmanage.entity.Subject;
import com.neuedu.studentmanage.mapper.SubjectMapper;
import com.neuedu.studentmanage.service.SubjectService;

@Service
@Transactional
public class SubjectServiceImpl implements SubjectService{
	@Autowired
	private SubjectMapper subjectMapper;
	
	@Override
	public List<Subject> findAll() {
		return subjectMapper.findAll();
	}

	@Override
	public List<Subject> findListByPager(Pager<Subject> pager) {
		return subjectMapper.findListByPager(pager);
	}

	@Override
	public Integer findTotalByPager(Pager<Subject> pager) {
		return subjectMapper.findTotalByPager(pager);
	}

	@Override
	public Result add(Subject subject) {
		Result result= new Result(false,"新增课程失败");
		boolean res= subjectMapper.add(subject);
		if(res) {
			result= new Result(true,"新增课程成功");
		}
		return result;
	}

	@Override
	public Result edit(Subject subject) {
		Result result = new Result(false,"修改课程失败");
		boolean res=subjectMapper.edit(subject);
		if(res) {
			result=new Result(true,"修改课程成功");
		}
		return result;
	}

	@Override
	public Result deleteByIds(List<Subject> ids) {
		Result result = new Result(false,"删除课程失败");
		boolean res= subjectMapper.deleteByIds(ids);
		if(res) {
			result= new Result(true,"删除课程成功");
		}
		return result;
	}

	

}
